const router = require('express').Router()

// 导入中间件
const { getBannerList } = require('../middleware/pages')
const { getUserDetails } = require('../middleware/users')
const { getGoodsList } = require('../middleware/goods')
const { cartList } = require('../middleware/cart')

// 专门配置各种页面的路由请求
router.get('/index', getBannerList, getUserDetails, (req, res) => { res.render('index.html', { list: req.banner, userInfo: req.userInfo }) })
router.get('/register', (req, res) => res.render('register.html', {}))
router.get('/login', (req, res) => res.render('login.html', {}))
router.get('/info', getUserDetails, (req, res) => res.render('info.html', { userInfo: req.userInfo }))
router.get('/goods', getUserDetails, getGoodsList, (req, res) => {
  res.render('goods.html', { userInfo: req.userInfo, pagi: req.pagi })
})
router.get('/cart', getUserDetails, cartList, (req, res) => {
  res.render('cart.html', { userInfo: req.userInfo, cartList: req.cartList })
})

module.exports = router
